<!-- 
    Security Knowledge Framework is an expert system application 
    that uses OWASP Application Security Verification Standard, code examples,
    helps developers in pre-development and post-development.  
    Copyright (C) 2020  Glenn ten Cate, Riccardo ten Cate

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as
    published by the Free Software Foundation, either version 3 of the
    License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program. If not, see <http://www.gnu.org/licenses/>.
-->

<!-- **********************************************************************************************************************************************************
      MAIN CONTENT
      *********************************************************************************************************************************************************** -->
<!--main content start-->

<section id="main-content" class="page03 project-list">
  <section class="intro">
    <div class="inner">
      <div class="text">
        <p>
          Overview of your current sprint items, export them to import them in
          your favourite ticketing system!
        </p>
      </div>
      <button style="float:right; margin-left: 1%" (click)="back()" class="btn btn-default">
        <i class="fa fa-arrow-left" aria-hidden="true"></i> Back
      </button>
      <button style="float:right;" (click)="export()" class="btn btn-success">
        <i class="fa fa-cloud-download" aria-hidden="true"></i> Export to CSV
      </button>
    </div>
  </section>
  <section class="wrapper" style="margin-top:0px;">
    <div class="row mt">
      <div class="col-lg-12">
        <ng-container>
          <ngb-accordion [closeOthers]="true" #acc="ngbAccordion">
            <div *ngFor="let item of sprintResult; let myIndex = index" class="content-panel"
              style="padding-bottom:0.25em; padding-top:2%;">
              <div *ngIf="item.kb_item_id != 1">
                <ngb-panel id="{{ myIndex }}"
                  title="{{ item.checklist_items_checklist_id }} {{item.checklist_items_content}} -- Resolved: {{ item.resolved }}">
                  <ng-template ngbPanelContent>
                    <ngb-tabset>
                      <ngb-tab>
                        <ng-template ngbTabTitle><b>Summary</b></ng-template>
                        <ng-template ngbTabContent>
                          <br />
                          <h4>{{ item.kb_item_title }}</h4>
                          <p style="white-space: pre-line; max-width:70%">
                            {{ item.kb_items_content }}
                          </p>
                          <div *ngIf="item.cwe > 0">
                            <ngb-alert [dismissible]="false">
                              <strong><a href="https://cwe.mitre.org/data/definitions/{{
                                    item.cwe
                                  }}.html" target="_blank" rel="noopener noreferrer">CWE {{ item.cwe }}</a></strong>
                            </ngb-alert>
                          </div>
                          <button (click)="deleteModal(modalDeleteChecklistResult)"
                            style="float:right; margin-left:1%; margin-bottom:1%; margin-right:1%" id="delete-button"
                            class="btn btn-danger btn-xs">
                            Delete result
                          </button>
                          <!-- start modal for deleting a checklist result-->
                          <ng-template #modalDeleteChecklistResult let-c="close" let-d="dismiss">
                            <div class="modal-header">
                              <h4 class="modal-title">
                                Delete sprint/feature!
                              </h4>
                              <button type="button" class="close" aria-label="Close" (click)="d('Cross click')">
                                <span aria-hidden="true">&times;</span>
                              </button>
                            </div>
                            <div class="modal-body">
                              <p>
                                Are you sure you want to delete this
                                sprint/feature?
                              </p>
                              <p>
                                To confirm, type
                                <b style="color:red"> DELETE </b> and click the
                                delete button
                              </p>
                              <input type="text" [(ngModel)]="delete" id="delete" class="form-control" />
                            </div>
                            <div class="modal-footer">
                              <button type="button" class="btn btn-secondary" (click)="c('Close click')">
                                Close
                              </button>
                              <button type="button" class="btn btn-danger" id="submit"
                                (click)="deleteChecklistResult(item.id)" (click)="c('Close click')">
                                Delete
                              </button>
                            </div>
                          </ng-template>
                        </ng-template>
                      </ngb-tab>

                      <ngb-tab>
                        <ng-template ngbTabTitle><b (click)="
                              complianceTabClickEvent(
                                item.evidence,
                                item.resolved
                              )
                            ">Compliance</b>
                        </ng-template>
                        <ng-template ngbTabContent>
                          <form [formGroup]="complianceForm">
                            <div class="form-group">
                              <div class="wrap">
                                <label for="inputVersion" maxlength="10" class="col-sm-2 control-label">
                                  evidence
                                </label>
                                <div class="col-sm-10">
                                  <textarea rows="10" style="height:100%;" formControlName="evidence" type="text"
                                    class="form-control"></textarea>
                                  <div class="wrap desc alert-info">
                                    <div class="col-sm-10">
                                      Provide testable evidence for the fix!
                                    </div>
                                  </div>
                                </div>
                              </div>
                            </div>
                            <div class="form-group">
                              <div class="wrap">
                                <label for="inputDesc" class="col-sm-2 control-label">Resolved?</label>
                                <div class="col-sm-10">
                                  <select class="form-control" formControlName="resolved" id="sel1">
                                    <option value="True">true</option>
                                    <option value="False">false</option>
                                  </select>
                                  <div class="wrap desc alert-info">
                                    <div class="col-sm-10">
                                      Was the control implemented successfully?
                                    </div>
                                  </div>
                                </div>
                              </div>
                            </div>
                            <button type="submit" class="btn btn-warning" id="create-project"
                              style="float:right; margin-top:1.5%; margin-right:1%; margin-bottom: 1%;"
                              (click)="updateChecklistResult(item.id)">
                              Update item
                            </button>
                          </form>
                        </ng-template>
                      </ngb-tab>
                    </ngb-tabset>
                  </ng-template>
                </ngb-panel>
              </div>
            </div>
          </ngb-accordion>
        </ng-container>
      </div>
      <!-- /col-lg-4 -->
    </div>
    <!-- /row -->
  </section>
  <!--/wrapper -->
</section>
<!-- /MAIN CONTENT -->